package org.manager.generic.Repository;

import org.hibernate.Criteria;
import org.hibernate.Session;

public class CriteriaUtil {
	private static String cacheRegion;
	
	@SuppressWarnings("unchecked")
	public static Criteria createCacheCriteria(Session session,Class className){
		Criteria criteria = session.createCriteria(className);
		if(cacheRegion != null){
			criteria.setCacheable(true);
			criteria.setCacheRegion(cacheRegion);
		}
		return criteria;
	}
	
	public void setCacheRegion(String cacheRegion) {
		CriteriaUtil.cacheRegion = cacheRegion;
	}

}
